#include <stdio.h>
#include <stdlib.h>

typedef short bo;

bo ans[34] = {0};
bo res[8] = {0};
int n = 0;

int main()
{
    int tmp;
    scanf("%d", &n);
    for (int i = 0; i < 7; ++i)
    {
        scanf("%d", &tmp);
        ans[tmp] = 1;
    }
    for (int i = 0; i < n; ++i)
    {
        int tmp2 = 0;
        for (int j = 0; j < 7; ++j)
        {
            scanf("%d", &tmp);
            tmp2 += ans[tmp];
        }
        res[tmp2 - 1] += 1;
    }
    for (int i = 6; i >= 0; --i)
    {
        printf("%d ", res[i]);
    }
    return 0;
}